package com.jymj.service.impl;

import com.jymj.dao.ExitDao;
import com.jymj.entity.SysUserEntity;
import com.jymj.entity.model.CommonEnumEnty;
import com.jymj.entity.zjd.ZjdCountEntity;
import com.jymj.entity.zjd.ZjdTcEntity;
import com.jymj.service.ExitService;
import com.jymj.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dl on 2019/10/15.
 */
@Service
@Transactional
public class ExitServiceImpl implements ExitService {
    @Autowired
    private ExitDao exitDao;

    @Override
    public List<ZjdTcEntity> queryList(Map<String, Object> params) {
        /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return exitDao.queryList(params);
    }

    @Override
    public int queryTotal(Map<String, Object> params) {
        /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return exitDao.queryTotal(params);
    }

    @Override
    public void save(ZjdTcEntity zjdTcEntity) {
        zjdTcEntity.setSptype(1);
        exitDao.save(zjdTcEntity);
    }

    @Override
    public int update(ZjdTcEntity zjdTcEntity) {
        return exitDao.update(zjdTcEntity);
    }

    @Override
    public ZjdTcEntity queryObject(Integer id) {
        return exitDao.queryObject(id);
    }

    @Override
    public boolean queryAllFile(Integer status, List<Integer> zjdTcFileIds) {
        List<CommonEnumEnty> commonEnumEnties = exitDao.queryAllFile(status,zjdTcFileIds);
        for (CommonEnumEnty  commonEnum:commonEnumEnties) {
            if(commonEnum.getKey1()==null || commonEnum.getStatus1()==null){
                return false;
            }
        }
        return true;
    }

    @Override
    public ZjdTcEntity queryObjectByylId(Integer objectid) {
        return exitDao.queryObjectByylId(objectid);
    }

    @Override
    public boolean queryCount(Integer sptype, Integer id) {
        Integer i = exitDao.queryCount(sptype,id);
        if (i < 1){
            return false;
        }
        return true;
    }

    @Override
    public List<ZjdTcEntity> queryListById(Integer[] ids) {
        return exitDao.queryListById(ids);
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        exitDao.deleteBatch(ids);
        exitDao.deleteFile(ids);
    }

    @Override
    public void updateYl(Integer ylId,Integer sptype) {
        exitDao.updateYl(ylId,sptype);
    }

    @Override
    public void updateYlAll(Integer[] ids, Integer sptype) {
        exitDao.updateYlAll(ids,sptype);
    }

    @Override
    public List<ZjdTcEntity> queryTypeCount(String xzqmc, Integer type) {
        Map map  = new HashMap();
        SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        map.put("sysUser",sysUserEntity);
        map.put("xzqmc",xzqmc);
        map.put("type",type);
        return exitDao.queryTypeCount(map);
    }

    @Override
    public ZjdCountEntity queryAllCount(String point, String code) {
        return exitDao.queryAllCount(point,code);
    }
}
